﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ServiceModel.Syndication;
using System.Xml;
using System.Net;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        // Blog feed
        SyndicationFeed blogFeed = new SyndicationFeed();

        try
        {

            // Read the feed using an XmlReader
            using (XmlReader reader = XmlReader.Create("http://nonadventures.com/feed/"))
            {
                // Load the feed into a SyndicationFeed
                blogFeed = SyndicationFeed.Load(reader);
            }
        }
        catch (Exception ex)
        {
            if (ex is WebException || ex is XmlException)
            {
                // Handle bad url, timeout or xml error here.
            }
            else
                throw;
        }
        // Use the feed
        string ConstructItem = null;
        string AuthorNames = null;
        foreach (SyndicationItem item in blogFeed.Items)
        {
            foreach (SyndicationPerson person in blogFeed.Authors)
            {
                AuthorNames = AuthorNames + ", " + person.Name;
            }
            foreach (SyndicationPerson person in item.Authors)
            {
                AuthorNames = AuthorNames + ", " + person.Name;
            }
            ConstructItem = "<b>" + blogFeed.Title.Text + "</b><br /><i>by " + AuthorNames + "</i><br />" + item.Title.Text;
            BulletedList1.Items.Add(new ListItem(ConstructItem));
            //Console.WriteLine(item.Title.Text);
        }
    }
    protected void BulletedList1_Click(object sender, BulletedListEventArgs e)
    {

    }

   
}